package tests;

import java.util.UUID;

/**
 * Created by IntelliJ IDEA.
 * User: qiukexu
 * Date: 2009-6-3
 * Time: 11:12:41
 */
public class TestUUID {
    public static void main1(String[] args) {
        UUID uuid = UUID.randomUUID();
        System.out.println("UUID="+uuid.toString());

        String highString = Long.toBinaryString(uuid.getMostSignificantBits());
        String lowString = Long.toBinaryString(uuid.getLeastSignificantBits());

        for(int i = highString.length() ; i < 64; i++){
            highString = new StringBuilder().append("0").append(highString).toString();
        }
        for(int i = lowString.length() ; i < 64; i++){
            lowString = new StringBuilder().append("0").append(lowString).toString();
        }

        System.out.println("H="+highString);
        System.out.println("L="+lowString);


        String s = highString+lowString;
        System.out.println("All="+s);
        System.out.println(s.length());
        System.out.println(Long.toHexString(uuid.getMostSignificantBits()));
        System.out.println(Long.toHexString(uuid.getLeastSignificantBits()));

        UUID newUuid = new UUID(uuid.getMostSignificantBits(),uuid.getMostSignificantBits());
        System.out.println(newUuid.equals(uuid));
    }

    public static void main(String[] args) {
        UUID uuid = UUID.nameUUIDFromBytes("e8900685303f7522a28eb082a28eb0c".getBytes());
        System.out.println(uuid.toString());
    }
}
